/*
 * @Description: 头部标题栏组件（包含右侧点击按钮）
 * @Author: buwei.huang
 * @Date: 2019-06-17 15:21:53
 * @Last Modified by: buwei.huang
 * @Last Modified time: 2019-06-17 15:22:39
 */
<template>
  <title-bar
    :titleText="name"
    rightText="去这里"
    :rightFunc="goHere"
  />
</template>
<script>
import TitleBar from '@/components/titlebar/TitleBar'
import { goToHere } from '@/utils/RouteTableUtils.js'
export default {
  components: {
    'title-bar': TitleBar
  },
  props: {
    busInfo: {
      type: Object,
      default: null
    },
    GPSinfo: {
      type: Object,
      default: null
    }
  },
  computed: {
    name() {
      if (this.busInfo) {
        return this.busInfo.NAME
      }
    }
  },
  methods: {
    // 去这里 跳转
    goHere() {
      // console.log('go~~~', this.busInfo)
      // console.log('go~~~', this.GPSinfo)
      let params = {
        START_ADRESS: this.GPSinfo.add ? this.GPSinfo.add : this.busInfo.NAME,
        START_LOACTION_LNG: this.GPSinfo.longitude ? this.GPSinfo.longitude : this.busInfo.START_LOACTION_LNG,
        START_LOACTION_LAT: this.GPSinfo.latitude ? this.GPSinfo.latitude : this.busInfo.START_LOACTION_LAT
      }
      let paramsStr = encodeURI(
        'START_ADRESS=' + params.START_ADRESS +
        '&START_LOACTION_LNG=' + params.START_LOACTION_LNG +
        '&START_LOACTION_LAT=' + params.START_LOACTION_LAT +
        '&END_ADRESS=' + this.busInfo.NAME +
        '&END_LOACTION_LNG=' + this.busInfo.START_LOACTION_LNG +
        '&END_LOACTION_LAT=' + this.busInfo.START_LOACTION_LAT
      )
      goToHere(paramsStr)
    }
  }
}
</script>
<style>
.title-bar-wrapper {
  background-color: #fff;
}
.title-bar-wrapper > .title-text {
  padding: 0 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-bar-wrapper > .right-btn {
  color: #333333;
}
</style>
